﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

using Lidgren.Network;


namespace IMLibrary
{
   
    /// <summary>
    /// UDP事件参数
    /// </summary>
    public class UDPEventArgs : EventArgs
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="allow"></param>
        /// <param name="data"></param>
        /// <param name="session"></param>
        public UDPEventArgs(bool allow, byte[] data, NetConnection session)
        {
            this.Allow = allow;
            this.Data = data;
            this.Session = session;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="serverID"></param>
        public UDPEventArgs(long serverID)
        {
            ServerID = serverID;
        }
        public UDPEventArgs(IPEndPoint remote)
        {
            Remote = remote;
        }
        /// <summary>
        /// P2P服务ID
        /// </summary>
        public long ServerID { get; set; }
        /// <summary>
        /// 远程节点
        /// </summary>
        public IPEndPoint Remote { get; set; } 
        /// <summary>
        /// 获取或设置消息内容 
        /// </summary>
        public byte[] Data { get; set; }
        /// <summary>
        /// 获取或设置请求客户端连接对像
        /// </summary>
        public NetConnection Session { get; set; }
        /// <summary>
        /// 获取或设置 标识用于纪录是否执行事件以后的操作 
        /// </summary>
        public bool Allow { get; set; }
        /// <summary>
        /// 获取消息字符串表示
        /// </summary>
        public string DataString
        {
            get { return Encoding.UTF8.GetString(Data); }
        }
    }
  
}
